/*
 * This file is part of SSHTTPD.
 *
 * SSHTTPD is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * SSHTTPD is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef _REQUEST_H
#define _REQUEST_H

/** @file
 * Defines global structures and functions implemented and used by request.c.
 */

/**
 * Holds the parsed details of a http request from the client.
 * The parsed strings are stored in bptr seperated by NULL char, each pointer is then
 * pointed to one of these strings to make up the structures values.
 */
typedef struct http_req_header {
        /** Request type. */
	char *request; 	
	/** Version specified. */
	char *ver; 
	/** URL requested. */
	char *url; 	
	/** Pointer to the original data. */
	char *bptr;         
	/** Integer value for the request type. */
	int reqcode; 
} httpr_t;

/** Value for request error. */
#define REQ_ERROR 1 
/** Value for "GET" request. */
#define REQ_GET 0 
/** Value for "HEADER" request. */
#define REQ_HEADER 2 
/** Value for POST request. */
#define REQ_POST 3 

/** 
 * Parses a request string into a httpr_t structure.
 * @param request Request string to parse.
 * @return Request structure with parsed info. Needs to be destroyed.
 * @see httpr_t, destroyrequest()
 */
httpr_t *reqparse(const char *request);

/** 
 * Destroys a http request structure. 
 * @param req Request to destroy.
 */
void destroyrequest(httpr_t *req); 

#endif
